/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package labb2.pkg2da;

import java.util.ArrayList;

/**
 *
 * @author Ninans
 */
public class arrays {
   
    boolean boolArray[] = new boolean[10];
    double doubleArray[] = new double[10];
    int intArray[] = new int[10];
    ArrayList array = new ArrayList();
    
    public arrays(){
        array.add(1);
        array.add(true);
        array.add(2.3);
        array.add(8);
        array.add(true);
        array.add(3.3);
        array.add(6);
        array.add(8);
        array.add(14);
        array.add(3.5);
        array.add(43);
        array.add(6.8);
        array.add(66);
        array.add(25);
        array.add(15.20);
        array.add(48);
        array.add(32.31);
        array.add(66.77);
        array.add(88);
        array.add(22.44);
    
       System.out.println("ArrayList content: ");
        for (int i = 0; i < array.size(); i++) {
            System.out.print(array.get(i) + " ");
        } 
        
        for (int i = 0; i < array.size(); i++) {
            if (array.get(i) instanceof Integer) {
                expandInt();
                intArray[intArray.length - 1] = (int) array.get(i);
            } else if (array.get(i) instanceof Double) {
                expandChar();
                doubleArray[doubleArray.length - 1] = (double) array.get(i);
            } else if (array.get(i) instanceof Boolean) {
                expandBool();
                boolArray[boolArray.length - 1] = (boolean) array.get(i);
            }
        }
 
 
        System.out.println("\n\nContent of Integer Array: ");
        for (int i = 0; i < intArray.length; i++) {  
            System.out.print(intArray[i] + " ");
        }
        System.out.println("\n\nContent of Double Array: ");
        for (int i = 0; i < doubleArray.length; i++) {
            System.out.print(doubleArray[i] + " ");
        }
        System.out.println("\n\nContent of Bool Array: ");
        for (int i = 0; i < boolArray.length; i++) {
            System.out.print(boolArray[i] + " ");
        }
        System.out.print("\n\n");
    }
 
    public void expandInt() {
        int array2[] = new int[intArray.length + 1];
 
        for (int i = 0; i < intArray.length; i++) {
            array2[i] = intArray[i];
           
        }
        intArray = array2;
    }
 
    public void expandChar() {
        double array2[] = new double[doubleArray.length + 1];
 
        for (int i = 0; i < doubleArray.length; i++) {
            array2[i] = doubleArray[i];
        }
 
        doubleArray = array2;
    }
 
    public void expandBool() {
        boolean array2[] = new boolean[boolArray.length + 1];
 
        for (int i = 0; i < boolArray.length; i++) {
            array2[i] = boolArray[i];
        }
 
        boolArray = array2;
    }
}